package com.duoduo.mall.config;


import com.duoduo.mall.interceptor.LoginCheckInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private LoginCheckInterceptor loginCheckInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry){
        registry.addInterceptor(loginCheckInterceptor).addPathPatterns("/**")//拦截所有请求
        .excludePathPatterns("/mall/user/login")//排除登录接口
        .excludePathPatterns("/mall/user/register")//排除注册接口
        .excludePathPatterns("/swagger-ui.html/**","/doc.html/**","/webjars/**","/swagger-resources/**");//排除swagger文档接口，webjars是swagger的依赖
    }

}
